#include <bits/stdc++.h>
using namespace std;

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int s[100005], vs[100005], a[100005];
    int p[100005];
    int t;
    cin >> t;
    while(t--){
        memset(s, 0, sizeof(s));
        memset(vs, 0, sizeof(vs));
        memset(a, 0, sizeof(a));
        memset(p, 0, sizeof(p));
        int n, m, l, v;
        cin >> n >> m >> l >> v;
        int ans = 0;
        for(int i=1;i<=n;i++){
            cin >> s[i] >> vs[i] >> a[i];
        }
        for(int i=1;i<=m;i++){
            cin >> p[i];
        }
        for(int i=1;i<=n;i++){
            if(s[i]<=p[m]&&a[i]==0){
                ans += (vs[i] <= v ? 0 : 1);
            }else if(s[i]<=p[m]&&a[i]>0){
                int dis = p[m] - s[i];
                double faster = sqrt(vs[i]*vs[i]*1.0+2.0*a[i]*dis);
                if(faster>v)
                    ans++;
            }
        }
        if(ans==0)
            m++;
        cout << ans << " " << m - 1 << endl;
    }
    return 0;
}
